package suse.hotel.admin.admin.Mapper;

import suse.hotel.admin.admin.Entity.RoomMessage;

import java.text.MessageFormat;
import java.util.List;
import java.util.Map;

public class RoomAdd {
    public String batStuAdd(Map map) {
        List<RoomMessage> students = (List<RoomMessage>) map.get("list");
        StringBuilder sb = new StringBuilder();
        sb.append("insert into tb_user(room_id,hotel_id,room_code,room_type,room_beds,room_price) values");
        MessageFormat mf = new MessageFormat("(#'{'list[{0}].phone},#'{'list[{0}].name},#'{'list[{0}].password})");
        for (int i = 0; i < students.size(); i++) {
            sb.append(mf.format(new Object[]{i}));
            if (i < students.size() - 1) {
                sb.append(",");
            }
        }
        return sb.toString();
    }

}
